import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';

@Injectable()
export class AddressService {
    constructor(@InjectModel('Address') private readonly addressModel) {}
    async find(where = {}, sort = { sort: 1, createdTime: -1 }, fields = null) {
        return await this.addressModel.find(where, fields).sort(sort);
    }
    async create(addressInfo) {
        return await this.addressModel.create(addressInfo);
    }
    async update(addressInfo) {
        return await this.addressModel.updateOne({ _id: addressInfo._id }, addressInfo);
    }
    async delete(addressInfo) {
        return await this.addressModel.deleteOne(addressInfo);
    }
    getModel() {
        return this.addressModel;
    }
}
